package com.chinackts.exceptionadvice.support.dingding;


import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import okhttp3.OkHttpClient;

public class SendDingForMD extends SendDing {

    public SendDingForMD(OkHttpClient okHttpClient, String url, String secret) {
        super(okHttpClient, url, secret);
    }

    public void send(final String title, final String text) {
        JSONObject content;
        try {
            content = new JSONObject() {
                {
                    put("msgtype", "markdown");
                    put("markdown", new JSONObject() {{
                        put("title", title);
                        put("text", text);
                    }});
                }
            };
        } catch (JSONException e) {
            throw new RuntimeException("发钉钉通知失败!", e);
        }
        super.send(content);
    }
}
